Test the pygame UI input primitives via injected events#98
Merged
Conversation
showDialogue, timedKeyPress, and promptForText drive pygame event loops and had no coverage — only the resize/font helpers were tested. A regression in their key handling (e.g. backspace or Enter-to-submit) would go unnoticed. Adds tests that inject events through a patched pygame.event.get (with the per-frame flip/clock stubbed): a keypress dismisses showDialogue and resets the prompt, timedKeyPress returns a non-negative reaction, and promptForText accumulates typed characters and honors backspace before Enter submits. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dmccoystephenson
left a comment
Member
Author
There was a problem hiding this comment.
Self-review:
- Scope: PASS — appends to the pygame test file; characterization only, no prod change.
- Tests-new: PASS — showDialogue/timedKeyPress/promptForText key handling (incl. backspace + Enter-submit) were previously uncovered.
- Headless-pygame: PASS — events injected via patched event.get; flip/Clock stubbed; CI green (218).
- Deterministic: PASS — no unseeded random; events are explicit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage B test-expansion (continued): the pygame interactive input primitives had zero coverage. This injects events through a patched
pygame.event.get(with the per-framedisplay.flip/Clockstubbed) to exercise their key handling.showDialogue: a keypress ends the wait and resets the prompt to "What would you like to do?"timedKeyPress: returns a non-negative float reaction time after a keypress.promptForText: accumulates typed characters, honors Backspace, and submits on Enter ("h","i",Enter→"hi";"a","b",Backspace,Enter→"a").Characterization only — no production code changed; runs headless under dummy SDL.
Test plan
SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy python3 -m pytest— 218 passed (4 new)🤖 Generated with Claude Code